﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Zocono.WCS.Infrastructure.ApllicationDto.Enums;

namespace Zocono.WCS.Infrastructure.ApllicationDto.WCSTaskDto
{
    public class SocketClientInfoDto: INotifyPropertyChanged
    {

        public virtual event PropertyChangedEventHandler PropertyChanged;

        protected void NotifyPropertyChanged(string info)
        {
            if (PropertyChanged != null)
            {

                PropertyChanged.Invoke(this, new PropertyChangedEventArgs(info));

            }
        }

        public long SocketID
        {
            get;set;
        }

        /// <summary>
        /// 设备号
        /// </summary>
        public string MachineCode
        {
            set;
            get;
        }

        /// <summary>
        /// 站号
        /// </summary>
        public string StationCode
        {
            set;
            get;
        }

        /// <summary>
        /// 服务器
        /// </summary>
        public string IP
        {
            set;
            get;
        }

        /// <summary>
        /// 端口号
        /// </summary>
        public int Port
        {
            set;
            get;
        }

        /// <summary>
        /// 超时毫秒
        /// </summary>
        public int OutTime
        {
            set;
            get;
        }

        /// <summary>
        /// 心跳秒
        /// </summary>
        public int HeartSecond
        {
            set;
            get;
        }

        /// <summary>
        /// 重连秒
        /// </summary>
        public int ConnectSecond
        {
            set;
            get;
        }

        /// <summary>
        /// 设备是否连接正常
        /// </summary>       
        private bool mIsConnected = true;
        public bool IsConnected
        {
            get
            {

                return this.mIsConnected;
            }
            set
            {
                if (this.mIsConnected != value)
                {
                    this.mIsConnected = value;
                    this.NotifyPropertyChanged("IsConnected");
                }
            }
        }

        /// <summary>
        /// 激活
        /// </summary>
        public bool IsActive
        {
            set;
            get;
        }


        /// <summary>
        /// 设备类型
        /// </summary>
        public EnumSocketDevice EnumSocketDevice
        {
            set;
            get;
        }

        public string mDescrip;

        /// <summary>
        /// 备注
        /// </summary>
        public string Descrip
        {
            set
            {
                if (this.mDescrip != value)
                {
                    this.mDescrip = value;
                    this.NotifyPropertyChanged("Descrip");
                }
            }
            get
            {
                return this.mDescrip;
            }
        }

        private string mBuffSend;
        public string BuffSend
        {
            set
            {
                if (this.mBuffSend != value)
                {
                    this.mBuffSend = value;
                    this.NotifyPropertyChanged("BuffSend");
                }
            }
            get
            {
                return this.mBuffSend;
            }
        }

        private string mBuffReceive;
        public string BuffReceive
        {
            set
            {
                if (this.mBuffReceive != value)
                {
                    this.mBuffReceive = value;
                    this.NotifyPropertyChanged("BuffReceive");
                }
            }
            get
            {
                return this.mBuffReceive;
            }
        }

        public System.Timers.Timer Timer;


        public string Value = "";

        public AutoResetEvent Reset = new AutoResetEvent(false);

        /// <summary>
        /// 信号灯等待时间毫秒
        /// </summary>
        //public int ResetMs
        //{
        //    set;
        //    get;
        //}



        //public bool WriteLog { set; get; } = true;

        public override string ToString()
        {
            return this.EnumSocketDevice.ToString();
        }

    }
}
